using System;
using TelerikMvcGridCustomBindingHelper.NHibernate.ORMIntegration;
using TelerikMvcGridCustomBindingHelper.ORMIntegration;

namespace TelerikMvcGridCustomBindingHelper.NHibernate.Exceptions
{
    public class NHibernateIntegrationException : Exception
    {
        public NHibernateIntegrationException()
            : base(string.Format("Failed to locate or instatiate an NHibernate integration object, please verify your implementation, it has to implements the interface {0}.", typeof(INHibernateIntegration))) { }
        
        public NHibernateIntegrationException(string message)
            : base(message) { }

        public NHibernateIntegrationException(IORMIntegration nHibernatIntegrationObject)
            : base(GetMessage(nHibernatIntegrationObject)) { }
        
        private static string GetMessage(IORMIntegration nHibernatIntegrationObject)
        {
            return string.Format("The NHibernate integration object \"{0}\" has to implement the interface \"{1}\".",
                nHibernatIntegrationObject.GetType(), typeof(INHibernateIntegration));
        }
    }
}